package com.budwk.app.sqfwV2.enums.centuryCitySafe;

import com.budwk.app.sqfwV2.dto.dto.centuryCity.SafeCheckTaskParamDataDTO;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * 企业安全生产主体问题数组
 */
@Getter
public enum EnterpriseSafetyProblemsEnum {

    ONE("1","makeEmergencyPlans", "是", "是否制定生产安全事故应急预案", "该企业未制定生产安全事故应急预案"),
    TWO("2","makeTrainingPlan", "是", "是否制定本年度安全生产教育培训计划", "该企业未制定本年度安全生产教育培训计划"),
    THREE("3","formulateFinancialInput", "是", "是否制定本年度安全生产资金投入计划", "该企业未制定本年度安全生产资金投入计划"),
    FORE("4","hiddenDangerControlSystem", "是", "是否制定安全生产隐患排查治理制度", "该企业未制定安全生产隐患排查治理制度"),
    FIVE("5","hiddenDangerLedger", "是", "是否制定安全生产隐患排查治理台账", "该企业未制定安全生产隐患排查治理台账"),
    SIX("6","housingAndBusinessTogether", "否", "住宅区域与经营、生产、仓储区域是否在同一空间", "该企业住宅区域与经营、生产、仓储区域在同一空间"),
    SEVEN("7","spaceSafetyResponsibility", "是", "是否建立有限空间作业安全责任制度", "该企业未建立有限空间作业安全责任制度"),
    SEVEN_ONE("8","doesSpaceApprovalSystem", "是", "作业是否按照有限空间审批制度", "该企业未建立有限空间作业审批制度"),
    EIGHT("9","spaceOperationSystem", "是", "是否建立有限空间作业现场安全管理制度", "该企业未建立有限空间作业现场安全管理制度"),
    EIGHT_ONE("10","trainingPlanImplemented", "是", "是否落实有限空间安全教育培训计划", "该企业未建立有限空间作业现场负责人、监护人员 、应急救援人员安全培训教育制度"),
    NINE("11","spaceEmergencyManagement", "是", "是否建立有限空间作业应急管理制度", "该企业未建立有限空间作业应急管理制度"),
    TEN("12","spaceManagementProcedure", "是", "是否建立有限空间作业安全管理规程", "该企业未建立有限空间作业安全管理规程"),
    TEN_one("13","electricalGasLines", "否", "电气线路是否存在私搭乱接裸露现象", "该企业电气线路私拉乱接"),
    ELEVEN("14","installTheSpraySystem", "是", "是否安装喷淋系统（含简易喷淋）", "该企业未安装喷淋系统（含简易喷淋）"),
    TWELVE("15","notEquippedFire", "是", "是否配备灭火器", "该企业未配备灭火器"),
    THIRTEEN("16","elecBicycleParkedCharged", "否", "是否存在电瓶车违规充电现象", "该企业存在电瓶车违规充电现象"),
    FORETEEN("17","blockageOfFireEscape", "否", "是否存在堵塞消防通道现象", "该企业存在堵塞消防通道现象"),
    FIFTEEN("18","applyForABusinessLicense", "是", "是否办理营业执照", "该企业未办理营业执照");

    private final String riskCode;

    private final String fields;

    private final String defaultValue;

    private final String riskDesc;

    // 问题隐患
    private final String harardDesc;

    EnterpriseSafetyProblemsEnum(String riskCode, String fields, String defaultValue, String riskDesc, String harardDesc) {
        this.riskCode = riskCode;
        this.fields = fields;
        this.defaultValue = defaultValue;
        this.riskDesc = riskDesc;
        this.harardDesc = harardDesc;
    }

    public static EnterpriseSafetyProblemsEnum getEnumByFields(String fields) {
        Optional<EnterpriseSafetyProblemsEnum> optional = Arrays.stream(values()).filter(e -> e.getFields().equals(fields)).findFirst();
        return optional.orElse(null);
    }

    /**
     * 获取问题的默认值
     * @return
     */
    public static List<SafeCheckTaskParamDataDTO> getDefaultValues() {
        List<SafeCheckTaskParamDataDTO> list = new ArrayList<>();
        for (EnterpriseSafetyProblemsEnum e : values()) {
            SafeCheckTaskParamDataDTO safe = new SafeCheckTaskParamDataDTO();
            safe.setKey(e.getDefaultValue()).setFields(e.getFields()).setRiskCode(e.getRiskCode()).setRiskDesc(e.getRiskDesc());
            list.add(safe);
        }
        return list;
    }
}
